package com.shenmazong.servertalkadmin.controller;

import com.shenmazong.pojo.TbClass;
import com.shenmazong.servertalkadmin.service.TbClassService;
import com.shenmazong.utils.ResponseResult;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
@Api(tags = "接口-课程管理微服务")
public class ClassManagerController {

    @Autowired
    private TbClassService tbClassService;

    /**
     * TODO 生成课表
     * @return
     */

    @PostMapping(value = "/makeClass")
    @ApiOperation(value = "添加课程信息",notes = "实体类添加")
    @ApiResponses({
            @ApiResponse(code=400,message="请求参数没填好"),
            @ApiResponse(code=404,message="请求路径没有或页面跳转路径不对") })
    public ResponseResult makeClass(@RequestBody TbClass tbClass) {


        return tbClassService. makeClass(tbClass);
    }

    /**
     * TODO 调课
     * @return
     */
    @ApiOperation(value = "调课",notes = "实体类修改")
    @ApiResponses({
            @ApiResponse(code=400,message="请求参数没填好"),
            @ApiResponse(code=404,message="请求路径没有或页面跳转路径不对") })
    @PostMapping(value = "/changeClass")
    public ResponseResult changeClass(@RequestBody TbClass tbClass) {
        return tbClassService.changeClass(tbClass);
    }

    /**
     * TODO 取消课程
     * @return
     */
    @ApiOperation(value = "删除课程信息",notes = "id删除")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name="id", value = "课程ID", dataType = "int", required=true, example = "0")
    })
    @PostMapping(value = "/closeClass")
    public ResponseResult closeClass(@RequestParam("id") Integer id) {

        return tbClassService.closeClass(id);
    }
    /**
     * TODO 查询所有课程
     * @return
     */
    @ApiOperation(value = "查询课程信息",notes = "根据分页查询")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name="pageCurrent", value = "起始页", dataType = "int", required=true, example = "0"),
            @ApiImplicitParam(name="pageSize", value = "每页几条", dataType = "int", required=true, example = "0"),
    })
    @PostMapping(value = "/classList")
    public ResponseResult classList(@RequestParam("pageCurrent") Integer pageCurrent,
                                    @RequestParam("pageSize") Integer pageSize){
        return tbClassService.classList(pageCurrent,pageSize);
    }
}
